package com.pb.wkflow.api.controller.assembler;

import com.pb.infra.oth.util.UserInfo;
import com.pb.wkflow.api.controller.assembler.mapper.WfSysJsonXmlDtoMapper;
import com.pb.wkflow.api.controller.request.ProcDefineCreateRequest;
import com.pb.wkflow.api.controller.request.ProcDefineJsonRequest;
import com.pb.wkflow.api.entity.WfSysJsonXmlEntity;
import org.camunda.bpm.engine.repository.ProcessDefinition;

/**
 * @author 苗益辉
 * @date 2022/9/13 17:29
 */
public class WfSysJsonXmlAssembler {

    private WfSysJsonXmlAssembler() {

    }


    public static WfSysJsonXmlEntity assemblerToQuery(ProcDefineJsonRequest request, UserInfo userInfo) {
        return WfSysJsonXmlDtoMapper.INSTANCE.assemblerToQuery(request, userInfo);
    }

    public static WfSysJsonXmlEntity assemblerToQuery(ProcDefineCreateRequest request,UserInfo userInfo) {
        return WfSysJsonXmlDtoMapper.INSTANCE.assemblerToQuery(request, userInfo);
    }

    public static WfSysJsonXmlEntity assemblerToSave(ProcDefineCreateRequest request, UserInfo userInfo,
                                                     Integer version) {
        WfSysJsonXmlEntity entity = WfSysJsonXmlDtoMapper.INSTANCE.assemblerToSave(request, userInfo);
        entity.setVer(version);
        return entity;
    }

    public static void assemblerToUpdate(ProcDefineCreateRequest request, WfSysJsonXmlEntity entity) {
        WfSysJsonXmlDtoMapper.INSTANCE.assemblerToUpdate(request, entity);
    }

    public static void assemblerToDeploy(WfSysJsonXmlEntity entity,
                                                       ProcessDefinition processDefinition) {

        WfSysJsonXmlDtoMapper.INSTANCE.assemblerToDeploy(processDefinition, entity);
    }
}
